package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.ReportCommissionInfoService;
import com.yixun.qfbao.apidto.*;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetAgentCommissionSummaryPageReqVo;
import com.yixun.qfbao.vo.GetAgentCustomerPremisesCommissionPageReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("getAgentCustomerPremisesCommissionPageHander")
public class GetAgentCustomerPremisesCommissionPageHander extends CommonAbstractHander {

    private static Logger logger= LoggerFactory.getLogger(GetAgentCustomerPremisesCommissionPageHander.class);

    @Autowired
    private ReportCommissionInfoService reportCommissionInfoService;

    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        GetAgentCustomerPremisesCommissionPageReqVo reqVo = (GetAgentCustomerPremisesCommissionPageReqVo)reqDto;
        AgentCustomerPremisesCommissionResDto resDto = new AgentCustomerPremisesCommissionResDto();
        AgentCustomerPremisesCommissionReqDto reqDto1 = reqVo.getParams();
        BaseResponseDTO<AgentCustomerPremisesCommissionResDto> res = new BaseResponseDTO<AgentCustomerPremisesCommissionResDto>();
        try{
            resDto = reportCommissionInfoService.agentCustomerPremisesCommissionPage(reqDto1);
        } catch (Exception e) {
            logger.error("getAgentCustomerPremisesCommissionPageHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg("获取机构佣金失败!");
        }
        res.setResData(resDto);
        res.setResult(resDto.getResult());
        return res;
    }
}
